package com.jason.lightreader.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)//去除空值
public class Result {
    private Integer code;
    private Object data;
    private String msg;

    private Result(){}

    public static Result get(Code code){
        Result result = new Result();
        result.code=code.getCode();
        result.msg=code.getMsg();
        return result;
    }

    public static Result get(Code code,String msg){
        Result result = new Result();
        result.code=code.getCode();
        result.msg=msg;
        return result;
    }

    public static Result get(Code code,Object data){
        Result result = new Result();
        result.code=code.getCode();
        result.msg=code.getMsg();
        result.data=data;
        return result;
    }

    public static Result get(Code code,Object data,String msg){
        Result result = new Result();
        result.code=code.getCode();
        result.msg=msg;
        result.data=data;
        return result;
    }
}
